package com.zut.movie.service.impl;

import com.zut.movie.context.BaseContext;
import com.zut.movie.entity.User;
import com.zut.movie.mapper.UserMapper;
import com.zut.movie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.embedded.netty.NettyWebServer;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public User getById(String openid) {
        return userMapper.getById(openid);
    }

    @Override
    public void insertId(String openid) {
        userMapper.insertId(openid);
    }

    @Override
    public void updateUserUrl(String avatarUrl) {
        Long id = BaseContext.getCurrentId();
        User user = new User();
        user.setId(id);
        user.setUserAvatarUrl(avatarUrl);
        userMapper.updateUser(user);
    }

    @Override
    public void updateUserName(String username) {
        Long id = BaseContext.getCurrentId();
        User user = new User();
        user.setId(id);
        user.setUserName(username);
        userMapper.updateUser(user);
    }
}
